Skip to content

feat(server): add M0 inbound admission cap and runtime decision log (CLO-1368) - #264

Closed
nullStack65 wants to merge 3 commits into
release/native-0.1.10from
feat/clo-1368-m0-inbound-admission-log
Closed

nullStack65 wants to merge 3 commits into
release/native-0.1.10from
feat/clo-1368-m0-inbound-admission-log

Conversation

@nullStack65

@nullStack65 nullStack65 commented Dec 4, 2026 •

Copy link
Copy Markdown
Owner

Deploy: fleet

Problem

Any sender can currently name a waking delivery class (next_turn, when_idle, steer_at_tool_boundary, or interrupt) and start a turn on another thread, including founder-mission working threads and standing seats. Status updates and routine/uncovered PR events therefore woke threads without recipient-side admission control, and there was no append-only runtime decision log to measure observe-mode vs enforce-mode routing (Bot Runtime Plan CLO-1368, M0 Items 2 and 3).

Attribution: Implemented by Builder (gemini-4-neon, t3/antigravity) against docs/architecture/bot-runtime-plan-20261201.md sections 7 and 11 (CLO-1368). Human review state: pending.

Changes

  1. Inbound Cap v0 (packages/shared/src/inboundAdmission.ts, apps/server/src/orchestration-v2/InboundAdmission.ts):
    • status and pr_routine events never wake a thread (digest and log_only respectively).
    • Authenticated system pr_actionable events evaluate before generic seat/founder-mission sender caps and wake only when the PR is linked/opened on the founder-mission thread or covered by the seat's active watch; uncovered or unauthenticated system PR events yield log_only (0 turns).
    • For remaining events, founder-mission threads accept only founders and own children; standing seats accept founders, their reportsTo chain, and own children.
    • All other deliveries cap at digest, and t3_thread_send returns both the effective deliveryClass and deliveryReason to the sender.
    • Wired once into Orchestrator.dispatchMessage (with Section 8.5 fail-safe fallback to digest on error), avoiding overlap with open PRs fix(server): route lane-ended events once per condition and detach settled launchers (CLO-1302) #238 and feat(orchestration): standing manager mailbox batches queued work founder-first #239.
  2. Append-only runtime_decisions decision log (apps/server/src/persistence/Migrations/125_RuntimeDecisions.ts, apps/server/src/persistence/RuntimeDecisions.ts):
    • Adds runtime_decisions(at, env, thread, kind, event_kind, recipient_founder_mission, input_digest, decision, reason, enforced) with SQLite CHECK constraints (kind IN ('inbound', 'placement'), inbound-only fields null for placement) and BEFORE UPDATE/BEFORE DELETE abort triggers.
    • Applies fail-closed audience & sensitive-content filtering before every write (I8) and skips duplicate writes on idempotent command replays.
    • Adds runtimeEnforcement: "off" | "observe" | "enforce" fork setting in ServerSettings, defaulting to "observe" (enforced = 0, shadow-only) with a clean switch to "enforce" (enforced = 1).
  3. Conformance & integration tests:
    • M0 exact check 1: Factory hijack sequence (CTO sends at 21:34:05, 21:45:29, 22:11:32) -> 0 turns; Product Designer run 481 covered system watch wakes seat while uncovered and routine PR events yield 0 turns; reportsTo chain send to idle seat yields a turn while peer send caps at digest.
    • M0 exact check 2 SQL query verified against runtime_decisions returning 0.
    • t3_thread_send sender return verified for capped deliveryClass and deliveryReason.

Verification

Verified on head 965fd14be6b38b5eee630740eec4a09a8819b7d5 (rebased onto origin/release/native-0.1.10 6382e077de):

  • vp fmt --check (20 changed files): pass (0 issues)
  • vp lint (19 changed TS files, 206 rules): pass (0 warnings, 0 errors)
  • vp run knip:check: 0 unused files/exports in changed files (pre-existing fork baseline findings unchanged)
  • vp run typecheck: packages/contracts OK, packages/shared OK, apps/server OK (0 errors)
  • packages/shared: vp test run src/inboundAdmission.test.ts — 13/13 passed
  • apps/server: vp test run src/persistence/RuntimeDecisions.test.ts src/persistence/Migrations.test.ts src/orchestration-v2/InboundAdmission.test.ts src/mcp/OrchestratorMcpService.activity.test.ts src/provider/AgentContextBudget.test.ts — 5 files, 39/39 passed

Not run locally:

  • Full repo-wide apps/web typecheck (unrelated pre-existing errors in Sidebar.logic.test.ts and botOrgTree.test.ts on base) and CI full suite.

Model: gemini-4-neon
Task: implementation
Agent: Builder
Harness: t3/antigravity
Model-family: Gemini
Model-generation: 4 Neon
Skills-SHA: nullStack65/closura-agent-config@da5f66450f9d69207369395f7a30686834767453; skills/github-repository-ops/SKILL.md (sha256:e3778c3a953bfa9e7bf5c9b9609b6d6c947cffa03366b3bc0f75bbb722b76784, installed matches source)
Refs: CLO-1368

…CLO-1368)

Implement M0 Items 2 and 3 from the Bot Runtime Plan (CLO-1368):

- Add pure Inbound Cap v0 in packages/shared/src/inboundAdmission.ts:
  status and routine PR events never wake a thread; authenticated system
  pr_actionable wakes only on a PR opened/linked by a founder-mission thread
  or covered by a seat's active watch; remaining events on founder-mission
  threads accept only founders and own children, and seats accept founders,
  their reportsTo chain, and own children; all other deliveries cap at digest.
- Wire inbound admission into Orchestrator.dispatchMessage (fail-safe to
  digest on error) and surface the effective deliveryClass and deliveryReason
  back to senders via ThreadManagementService and t3_thread_send.
- Add migration 125_RuntimeDecisions.ts and append-only RuntimeDecisionStore
  (with SQLite CHECK constraints, update/delete abort triggers, and
  fail-closed audience filtering before write) supporting both inbound and
  placement decision records.
- Add runtimeEnforcement server setting defaulting to observe (logs decisions
  with enforced=0 without capping) with a clean switch to enforce or off.
- Add conformance unit tests for M0 exact checks 1 and 2 across shared,
  persistence, orchestrator, and MCP layers.

Refs: CLO-1368

Model: gemini-4-neon
Task: implementation
Agent: Builder
Harness: t3/antigravity
Model-family: Gemini
Model-generation: 4 Neon
Skills-SHA: nullStack65/closura-agent-config@da5f664; skills/github-repository-ops/SKILL.md (sha256:e3778c3a953bfa9e7bf5c9b9609b6d6c947cffa03366b3bc0f75bbb722b76784, installed matches source)
@coderabbitai

coderabbitai Bot commented Dec 4, 2026 •

Copy link
Copy Markdown

Important

  • Trigger review

This repository does not receive automatic reviews because it has fewer than 10 stars.

Run configuration

  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

@nullStack65

Copy link
Copy Markdown
Owner Author

Clean-room full review #1 of 2 (Tier 3) for PR #264 against Bot Runtime Plan (docs/architecture/bot-runtime-plan-20261201.md) sections 7, 8.5, and 11 (M0 items 2–3, exact checks 1–2).

Summary

The core architecture (pure admitInbound in packages/shared/src/inboundAdmission.ts, append-only runtime_decisions migration 125_RuntimeDecisions.ts with CHECK constraints and BEFORE UPDATE/BEFORE DELETE abort triggers, fail-closed audience/sensitive-content filtering, runtimeEnforcement defaulting to "observe", and M0 exact checks 1–2 coverage) is well structured and clean. Found 3 important correctness defects and 1 nit:

  1. F1 (important) — apps/server/src/orchestration-v2/InboundAdmission.ts:88: ACTIONABLE_PR_SUMMARY_RE uses \b(...|comment|...|awaiting approval)\b, which does not match pullRequestWatch.ts summary strings "#<n>: new comments" (plural, outcome: "updated", emitted for all PR review remarks including changes requested) or "#<n>: checks await approval" (outcome: "updated"). In enforce mode, covered PR review-comment / changes-requested wakes and checks-awaiting-approval wakes are misclassified as pr_routine and dropped as log_only.
  2. F2 (important) — packages/shared/src/inboundAdmission.ts:81: DEFAULT_SEAT_REPORTS_TO omits gardening: "cto" (defined in config/standing-threads.json, and Gardening is one of the first three enforcement roles in section 7.5). isInReportsToChain("CTO", "Gardening") and isInReportsToChain("CEO", "Gardening") return false, causing CTO/CEO handoffs to Gardening to be misclassified as peer -> status and capped at digest.
  3. F3 (important) — apps/server/src/orchestration-v2/InboundAdmission.ts:372: applyInboundAdmissionToCommand leaves dispatchMode unchanged when admission.deliverAs === "steer_at_tool_boundary". If a chain, child, or delegator sends interrupt (dispatchMode: { type: "restart_active", targetRunId }), admitInbound caps it to steer_at_tool_boundary, but restart_active is preserved and still restarts the active turn in CommandPolicy.resolveMessageDispatch.
  4. F4 (nit) — apps/server/src/mcp/OrchestratorMcpService.ts:4084: deliveryReason is populated from result.inboundAdmission?.reason even in observe mode (enforced === false), returning a capped reason (e.g., "status never starts a turn") alongside an uncapped deliveryClass ("next_turn").
{
  "reviewed_base": "6382e077dede0c225c1cac0c7b2c4ec14e0a04a8",
  "reviewed_head": "965fd14be6b38b5eee630740eec4a09a8819b7d5",
  "reviewer": "gemini-4-neon, t3/antigravity",
  "author_session": "mcp:launch:7aeae44da2405bd57e60ae88cb8c8a34d10c920bd7a031ab1fced22102bdd079",
  "reviewer_session": "2318a245-a08e-487f-86ce-8dded636e0cf",
  "fresh_context": true,
  "review_kind": "full",
  "round_id": "2318a245-a08e-487f-86ce-8dded636e0cf",
  "intent": [
    "CLO-1368 M0-2/3: implement Inbound Cap v0 in packages/shared/src/inboundAdmission.ts and append-only runtime_decisions log in observe mode"
  ],
  "prior_findings": [],
  "findings": [
    {
      "id": "F1",
      "severity": "important",
      "summary": "ACTIONABLE_PR_SUMMARY_RE uses singular \\bcomment\\b and 'awaiting approval', missing PullRequestWatchReactor's actual summaries '#<n>: new comments' (used for all review remarks including changes requested, with outcome 'updated') and '#<n>: checks await approval' (outcome 'updated'). In enforce mode, covered PR review-comment and checks-awaiting-approval wakes are misclassified as pr_routine and dropped as log_only.",
      "outcome": "open",
      "file": "apps/server/src/orchestration-v2/InboundAdmission.ts",
      "line": 88,
      "check": "node -e 're.test(\"#481: new comments\") -> false; re.test(\"#481: checks await approval\") -> false' (compared against SUMMARY in apps/server/src/orchestration-v2/pullRequestWatch.ts:513-523)"
    },
    {
      "id": "F2",
      "severity": "important",
      "summary": "DEFAULT_SEAT_REPORTS_TO omits gardening: 'cto' (present in config/standing-threads.json; Gardening is one of the first three enforcement roles in plan section 7.5). CTO/CEO sends to Gardening return false from isInReportsToChain, are misclassified as peer status, and are capped at digest in enforce mode.",
      "outcome": "open",
      "file": "packages/shared/src/inboundAdmission.ts",
      "line": 81,
      "check": "Compared DEFAULT_SEAT_REPORTS_TO against origin/master:config/standing-threads.json roles (gardening reportsTo cto is missing)"
    },
    {
      "id": "F3",
      "severity": "important",
      "summary": "applyInboundAdmissionToCommand does not downgrade dispatchMode from restart_active to steer_active when admitInbound caps interrupt down to steer_at_tool_boundary (e.g., chain/child/delegator interrupt send), so CommandPolicy.resolveMessageDispatch still restarts the active turn.",
      "outcome": "open",
      "file": "apps/server/src/orchestration-v2/InboundAdmission.ts",
      "line": 372,
      "check": "Inspected applyInboundAdmissionToCommand (lines 354-379) and CommandPolicy.resolveMessageDispatch (lines 105-136)"
    },
    {
      "id": "F4",
      "severity": "nit",
      "summary": "In observe mode (enforced === false), t3_thread_send still returns inboundAdmission.reason as deliveryReason even when capped === true, pairing an uncapped deliveryClass (e.g. next_turn) with a reason saying it was capped at digest.",
      "outcome": "open",
      "file": "apps/server/src/mcp/OrchestratorMcpService.ts",
      "line": 4084,
      "check": "Inspected OrchestratorMcpService.ts lines 4078-4095"
    }
  ]
}

…368)

Address clean-room review findings F1-F4 on the M0 inbound admission cap:
- F1: match pullRequestWatch 'new comments' and 'checks await approval' summaries as pr_actionable.
- F2: add 'gardening: cto' to DEFAULT_SEAT_REPORTS_TO.
- F3: downgrade restart_active to steer_active when applyInboundAdmissionToCommand caps interrupt to steer_at_tool_boundary.
- F4: omit capped deliveryReason in t3_thread_send when runtimeEnforcement is observe (enforced=false) so it does not contradict the uncapped deliveryClass.

Model: gemini-4-neon
Task: fix
Agent: Builder
Harness: t3/antigravity
Model-family: Gemini
Model-generation: 4 Neon
Skills-SHA: nullStack65/closura-agent-config@da5f664; skills/github-repository-ops/SKILL.md (sha256:e3778c3a953bfa9e7bf5c9b9609b6d6c947cffa03366b3bc0f75bbb722b76784, installed matches source)
Refs: CLO-1368
@nullStack65

Copy link
Copy Markdown
Owner Author

Clean-room full review #2 of 2 (Tier 3 quorum) at head ca33e76bc9408250fbb6f62730212634a88d4370 against bot-runtime-plan sections 7 and 11 (M0 items 2–3, exact checks 1–2).

What I read: the full diff (20 files), admitInbound and the server classifier, the Orchestrator wiring and the other dispatchMessage callers, migration 125, the store, the contracts, the MCP t3_thread_send result, and the notification producers (ProviderContinuationService, PeerLinkRequests, provider-core/server/notification.ts). DEFAULT_SEAT_REPORTS_TO matches config/standing-threads.json on closura-agent-config master (27b4f75f41).

What I ran (disposable worktree at the head, vp i):

  • packages/shared: vp test run src/inboundAdmission.test.ts: 13/13 passed.
  • apps/server: vp test run on RuntimeDecisions, Migrations, InboundAdmission, OrchestratorMcpService.activity, plus my uncommitted scratch reproduction: 5 files, 41/41 passed.
  • Scratch reproduction (enforce mode, ordinary agent thread, creationSource: "provider"). It used the notifications that backgroundWorkNotification builds for a thread's own wakes:
    • a Claude Monitor wake ("Monitor reported new output") came back log_only with the reason "routine PR events never wake a thread", and no message or run was created;
    • a background-task wake (Background task "Scheduled wakeup" finished) came back digest with the reason "sender is outside the thread's waking allowlist", leaving one queued digest run and 0 started.

Findings

  • F1 (important): the thread's own provider wakes are classified as inbound system events.
    • Every notification.source.kind === "monitor" without staleWaits is treated as a PR event (line 227). Claude's Monitor-tool wake has no PR stamp, so it becomes pr_routine and then log_only, which drops it under enforce.
    • background_task and system sources fall through to alert (line 239), which is capped at digest for every kind of recipient. That covers ScheduleWakeup, mixed background reports, the ProviderContinuationService default and PeerLinkRequests outcomes.
    • isInternalDispatchCommand exempts none of these. Under enforce, agents stall after their own background work; in observe, the decision log overstates caps.
    • Fix: exempt the thread's own continuation wakes (or classify monitor-without-PR and background_task as child/own-work), and add a regression test.
  • F2 (important): migration id 125 collides with upstream's next migration.
    • Migrations.ts:145 says upstream migrations "from 97 on register at their upstream id plus this offset, as does every later one" (+6).
    • Upstream main already has 119_WorkflowRunSubject, which maps to 125. This PR claims 125 for RuntimeDecisions and only narrows the ledger test to <= 118+offset.
    • Once the fleet records 125=RuntimeDecisions, a sync that follows the documented rule registers a second 125. assertV2MigrationsCanRun then refuses startup with BadState.
    • Fix: update the offset comment and the upstream-sync doc to record the new mapping (upstream ≥119 → +7), and assert manifest ids are unique.
  • F3 (nit): founder-mission PR coverage (InboundAdmission.ts:141) accepts any linked PR, including agent/stack links that another bot can add. M0 item 2 says "a PR opened by the founder thread"; the created link source and branch PR are closer to that.
  • F4 (nit): the exact-check-2 query (test line 474, copied from the plan) matches 'steer', but the log stores steer_at_tool_boundary/interrupt. As written, the query cannot detect a steer-class leak. Use the logged class names.
  • F5 (nit): the inboundEventKind wire field on message.dispatch (orchestrationV2.ts:4132) has no producer, so it adds unused contract surface.
  • F6 (nit): under enforce, "checks passed" is pr_routine, which is log_only: the event is dropped, not digested. The watch_pull_request docs still promise a wake on passed required checks, so until: "merged" watchers lose their trigger. The behaviour follows the plan's table, but the docs and enforce rollout need a note.
  • F7 (nit): a founder-created scheduled task bound to a founder-mission thread is capped at digest (shared/inboundAdmission.ts:263). This follows the M0 text literally. Confirm it is intended before switching to enforce.

Exact checks: exact check 1 (Factory sequence 0 turns, covered vs uncovered/routine watch, chain wakes an idle seat) and exact check 2 (query returns 0) both pass as fixtures. Observe is the default, so nothing is capped until enforce.

{
  "reviewed_base": "6382e077dede0c225c1cac0c7b2c4ec14e0a04a8",
  "reviewed_head": "ca33e76bc9408250fbb6f62730212634a88d4370",
  "reviewer": "claude-opus-5-5 (t3/antigravity)",
  "author_session": "mcp:launch:7aeae44da2405bd57e60ae88cb8c8a34d10c920bd7a031ab1fced22102bdd079",
  "reviewer_session": "antigravity:bc4026d5-1a03-4fc4-8f18-6039088cb30c",
  "fresh_context": true,
  "review_kind": "full",
  "round_id": "antigravity:bc4026d5-1a03-4fc4-8f18-6039088cb30c",
  "intent": ["CLO-1368 M0-2/3: implement Inbound Cap v0 in packages/shared/src/inboundAdmission.ts and append-only runtime_decisions log in observe mode"],
  "prior_findings": [],
  "findings": [
    {
      "id": "F1",
      "severity": "important",
      "outcome": "open",
      "file": "apps/server/src/orchestration-v2/InboundAdmission.ts",
      "line": 227,
      "summary": "The thread's own provider wakes are treated as inbound system events. A monitor notification without a PR stamp (Claude Monitor wake) becomes pr_routine/log_only and is dropped under enforce. background_task/system sources (ScheduleWakeup, mixed background reports, ProviderContinuationService default, PeerLinkRequests outcomes) fall to alert and are capped at digest for every recipient. isInternalDispatchCommand exempts none of them. Reproduced at head: Monitor wake gave log_only with 0 runs; background-task wake gave digest with 0 started runs."
    },
    {
      "id": "F2",
      "severity": "important",
      "outcome": "open",
      "file": "apps/server/src/persistence/Migrations.ts",
      "line": 273,
      "summary": "Fork migration RuntimeDecisions takes ledger id 125. Under the documented +6 offset (line 145: every later upstream migration registers at id+6), that id belongs to upstream 119_WorkflowRunSubject, which already exists on upstream main. Deployed fleet DBs will record 125=RuntimeDecisions, and a sync that follows the documented rule fails assertV2MigrationsCanRun (BadState) at startup. Update the offset doc and upstream-sync doc for the new mapping, and assert manifest ids are unique."
    },
    {
      "id": "F3",
      "severity": "nit",
      "outcome": "open",
      "file": "apps/server/src/orchestration-v2/InboundAdmission.ts",
      "line": 141,
      "summary": "Founder-mission PR coverage accepts any linked PR, including agent/stack links another bot can add. The spec says PR opened by the founder thread, which the created link source and branch PR match more closely."
    },
    {
      "id": "F4",
      "severity": "nit",
      "outcome": "open",
      "file": "apps/server/src/orchestration-v2/InboundAdmission.test.ts",
      "line": 474,
      "summary": "The exact-check-2 query matches 'steer', but the log stores steer_at_tool_boundary/interrupt, so the query as written cannot detect a steer-class leak."
    },
    {
      "id": "F5",
      "severity": "nit",
      "outcome": "open",
      "file": "packages/contracts/src/orchestrationV2.ts",
      "line": 4132,
      "summary": "The new inboundEventKind wire field on message.dispatch has no producer; it adds unused contract surface."
    },
    {
      "id": "F6",
      "severity": "nit",
      "outcome": "open",
      "file": "apps/server/src/orchestration-v2/InboundAdmission.ts",
      "line": 95,
      "summary": "Under enforce, checks-passed events are pr_routine/log_only (dropped, not digested), while the watch_pull_request docs still promise a wake on passed required checks. until=merged watchers lose their trigger. This follows the plan's table, but the docs and enforce rollout need a note."
    },
    {
      "id": "F7",
      "severity": "nit",
      "outcome": "open",
      "file": "packages/shared/src/inboundAdmission.ts",
      "line": 263,
      "summary": "A founder-created scheduled task bound to a founder-mission thread is capped at digest and never starts under enforce. This follows the M0 text literally; confirm it is intended before switching to enforce."
    }
  ]
}

…ork migration ledger (CLO-1368)

Address clean-room review 2/2 (Opus) findings on PR #264:
- Opus F1: bypass inbound admission for a thread's own provider continuations (creationSource === 'provider' or commandId starting with 'provider-continuation:'), and only classify monitor notifications with a PR stamp (pullRequest / otherPullRequests) or 'message:pr-watch:' prefix as pr_actionable/pr_routine so background_task and non-PR monitor wakes pass through as child/child_result under enforce.
- Opus F2: move RuntimeDecisions out of effect_sql_migrations (avoiding collision with upstream 119_WorkflowRunSubject under the +6 offset) into Migrations/fork/001_RuntimeDecisions.ts tracked in a dedicated closura_sql_migrations table without advancing effect_sql_migrations MAX(migration_id) or writing under PRAGMA query_only = ON.

Model: gemini-4-neon
Task: fix
Agent: Builder
Harness: t3/antigravity
Model-family: Gemini
Model-generation: 4 Neon
Skills-SHA: nullStack65/closura-agent-config@da5f664; skills/github-repository-ops/SKILL.md (sha256:e3778c3a953bfa9e7bf5c9b9609b6d6c947cffa03366b3bc0f75bbb722b76784, installed matches source)
Refs: CLO-1368
@nullStack65

Copy link
Copy Markdown
Owner Author

Focused re-check of F1 and F2 for PR #264 at head 18436729ac06d036b738faaa8afe5a2ac71a7f1f (delta ca33e76..1843672). F3–F7 retained unchanged. Not a second full review. Verified by static source reading; tests were not run because this checkout has no installed dependencies.

F1 (important): confirmed fixed. In InboundAdmission.ts, isInternalDispatchCommand now also exempts creationSource === "provider" and commandId prefix provider-continuation:. evaluateInboundDispatch now classifies background_task and non-PR monitor notifications as child/child_result. A monitor counts as PR-bound only with a pullRequest, otherPullRequests or a message:pr-watch: messageId. This covers the PeerLinkRequests and ProviderContinuationService background_task sources. New tests assert the following:

  • A provider-source monitor wake and a continuation wake have no inboundAdmission and start a run.
  • A background-task wake and a non-PR monitor wake get next_turn with wakesThread: true.
  • A redirected PR watch stays log_only.

F2 (important): confirmed fixed. RuntimeDecisions moved from ledger id 125 to Migrations/fork/001_RuntimeDecisions.ts. It is tracked in a separate closura_sql_migrations table (closuraForkMigrationManifest). Upstream ids now end at 118+6=124, so no collision with upstream 119 is possible. hasPendingMigrations and runMigrations account for the fork ledger, and each fork migration runs in a transaction together with its ledger insert. Migrations.test.ts asserts that fork files match the manifest and covers fork-ledger history.

{
  "reviewed_base": "6382e077dede0c225c1cac0c7b2c4ec14e0a04a8",
  "reviewed_head": "18436729ac06d036b738faaa8afe5a2ac71a7f1f",
  "reviewer": "claude-sonnet-5-5 (t3/antigravity)",
  "author_session": "mcp:launch:7aeae44da2405bd57e60ae88cb8c8a34d10c920bd7a031ab1fced22102bdd079",
  "reviewer_session": "antigravity:019b7c45-80e8-4f92-82d0-38de1649a043",
  "fresh_context": true,
  "review_kind": "focused_recheck",
  "round_id": "antigravity:bc4026d5-1a03-4fc4-8f18-6039088cb30c",
  "intent": ["CLO-1368 M0-2/3: implement Inbound Cap v0 in packages/shared/src/inboundAdmission.ts and append-only runtime_decisions log in observe mode"],
  "prior_findings": ["F1", "F2"],
  "findings": [
    {
      "id": "F1",
      "severity": "important",
      "outcome": "confirmed",
      "rechecked_head": "18436729ac06d036b738faaa8afe5a2ac71a7f1f",
      "file": "apps/server/src/orchestration-v2/InboundAdmission.ts",
      "line": 233,
      "summary": "The thread's own provider wakes are treated as inbound system events. A monitor notification without a PR stamp (Claude Monitor wake) becomes pr_routine/log_only and is dropped under enforce. background_task/system sources (ScheduleWakeup, mixed background reports, ProviderContinuationService default, PeerLinkRequests outcomes) fall to alert and are capped at digest for every recipient. isInternalDispatchCommand exempts none of them. Reproduced at head: Monitor wake gave log_only with 0 runs; background-task wake gave digest with 0 started runs. Re-check at 1843672: provider-source and provider-continuation commands are now internal; background_task and non-PR monitor notifications classify as child_result; new tests cover each."
    },
    {
      "id": "F2",
      "severity": "important",
      "outcome": "confirmed",
      "rechecked_head": "18436729ac06d036b738faaa8afe5a2ac71a7f1f",
      "file": "apps/server/src/persistence/Migrations.ts",
      "line": 278,
      "summary": "Fork migration RuntimeDecisions takes ledger id 125. Under the documented +6 offset (line 145: every later upstream migration registers at id+6), that id belongs to upstream 119_WorkflowRunSubject, which already exists on upstream main. Deployed fleet DBs will record 125=RuntimeDecisions, and a sync that follows the documented rule fails assertV2MigrationsCanRun (BadState) at startup. Update the offset doc and upstream-sync doc for the new mapping, and assert manifest ids are unique. Re-check at 1843672: RuntimeDecisions moved to a separate closura_sql_migrations ledger (fork/001), so upstream ids no longer collide; migration tests assert the fork manifest."
    },
    {
      "id": "F3",
      "severity": "nit",
      "outcome": "open",
      "file": "apps/server/src/orchestration-v2/InboundAdmission.ts",
      "line": 141,
      "summary": "Founder-mission PR coverage accepts any linked PR, including agent/stack links another bot can add. The spec says PR opened by the founder thread, which the created link source and branch PR match more closely."
    },
    {
      "id": "F4",
      "severity": "nit",
      "outcome": "open",
      "file": "apps/server/src/orchestration-v2/InboundAdmission.test.ts",
      "line": 474,
      "summary": "The exact-check-2 query matches 'steer', but the log stores steer_at_tool_boundary/interrupt, so the query as written cannot detect a steer-class leak."
    },
    {
      "id": "F5",
      "severity": "nit",
      "outcome": "open",
      "file": "packages/contracts/src/orchestrationV2.ts",
      "line": 4132,
      "summary": "The new inboundEventKind wire field on message.dispatch has no producer; it adds unused contract surface."
    },
    {
      "id": "F6",
      "severity": "nit",
      "outcome": "open",
      "file": "apps/server/src/orchestration-v2/InboundAdmission.ts",
      "line": 95,
      "summary": "Under enforce, checks-passed events are pr_routine/log_only (dropped, not digested), while the watch_pull_request docs still promise a wake on passed required checks. until=merged watchers lose their trigger. This follows the plan's table, but the docs and enforce rollout need a note."
    },
    {
      "id": "F7",
      "severity": "nit",
      "outcome": "open",
      "file": "packages/shared/src/inboundAdmission.ts",
      "line": 263,
      "summary": "A founder-created scheduled task bound to a founder-mission thread is capped at digest and never starts under enforce. This follows the M0 text literally; confirm it is intended before switching to enforce."
    }
  ]
}

@nullStack65

Copy link
Copy Markdown
Owner Author

Note

🤖 Grok 4.7 responding on behalf of nullStack65

Focused re-check of Neon round 2318a245-a08e-487f-86ce-8dded636e0cf on head 18436729ac06d036b738faaa8afe5a2ac71a7f1f (repair range 965fd14be6b38b5eee630740eec4a09a8819b7d5..18436729ac06d036b738faaa8afe5a2ac71a7f1f). F1 and F3 are confirmed. F4 is fixed. F2 is not confirmed.

F1. ACTIONABLE_PR_SUMMARY_RE is now comments? and await(?:ing)? approval. Against pullRequestWatch.ts summaries, #482: new comments and #482: checks await approval match, and #482: checks passed does not. Enforce-mode test classifies pullRequestWatch new comments and checks await approval summaries as actionable passed (pr_actionable / next_turn, wakes the thread).

F2. The patch adds gardening: "cto" at packages/shared/src/inboundAdmission.ts:94, and isInReportsToChain("CTO"|"CEO", "Gardening") is true. The cited registry does not have that edge. config/standing-threads.json at the plan pin 5769633bd95e and at closura-agent-config 943f200f69 leaves the gardening role with no reportsTo (Platform and ARC Ops do report to cto). The map comment says it mirrors that file. This edge makes CTO and CEO chain senders for Gardening. Left open.

F3. When a cap delivers steer_at_tool_boundary, applyInboundAdmissionToCommand rewrites restart_active to steer_active and drops deliveryIntent. Orchestrator.ts then derives intent steer, and resolveDeliveryIntent returns steer_active rather than restart_active. Unit test downgrades restart_active to steer_active when capped to steer_at_tool_boundary passed.

F4. In observe mode with capped === true, deliveryReason is omitted, so an uncapped deliveryClass is no longer paired with a cap reason. Enforced caps still return the reason. Test sendToThread omits capped deliveryReason in observe mode and reports it when enforced passed.

Tests run at this head, with dependencies linked from an existing checkout: packages/shared inboundAdmission.test.ts 13/13 passed; server filter new comments|steer_active|deliveryReason passed 3 and skipped 16. CI on this head was still queued when this comment was written.

{
  "reviewed_base": "6382e077dede0c225c1cac0c7b2c4ec14e0a04a8",
  "reviewed_head": "18436729ac06d036b738faaa8afe5a2ac71a7f1f",
  "reviewer": "grok-4.7 (t3/grok-direct)",
  "author_session": "mcp:launch:7aeae44da2405bd57e60ae88cb8c8a34d10c920bd7a031ab1fced22102bdd079",
  "reviewer_session": "grok-direct:01a2402e-2a09-7fe2-ac24-d3b00f223111",
  "fresh_context": true,
  "review_kind": "focused_recheck",
  "round_id": "2318a245-a08e-487f-86ce-8dded636e0cf",
  "intent": [
    "CLO-1368 M0-2/3: implement Inbound Cap v0 in packages/shared/src/inboundAdmission.ts and append-only runtime_decisions log in observe mode"
  ],
  "prior_findings": ["F1", "F2", "F3", "F4"],
  "findings": [
    {
      "id": "F1",
      "severity": "important",
      "outcome": "confirmed",
      "rechecked_head": "18436729ac06d036b738faaa8afe5a2ac71a7f1f",
      "file": "apps/server/src/orchestration-v2/InboundAdmission.ts",
      "line": 90,
      "summary": "ACTIONABLE_PR_SUMMARY_RE now matches pullRequestWatch summaries '#<n>: new comments' and '#<n>: checks await approval' (comments? and await(?:ing)? approval). Enforce-mode dispatch of those updated outcomes is pr_actionable and wakes the covered seat.",
      "check": "node regex samples matched both producer strings and rejected '#482: checks passed'; vp test run apps/server InboundAdmission.test.ts -t 'new comments' passed at 18436729ac06d036b738faaa8afe5a2ac71a7f1f"
    },
    {
      "id": "F2",
      "severity": "important",
      "outcome": "open",
      "file": "packages/shared/src/inboundAdmission.ts",
      "line": 94,
      "summary": "The repair adds gardening: cto, so CTO and CEO are in Gardening's reportsTo chain. config/standing-threads.json at plan pin 5769633bd95e and closura-agent-config 943f200f69 has no reportsTo on the gardening role. The original registry claim is not true, and the new edge is not confirmed.",
      "check": "python compare of standing-threads roles: gardening reportsTo is absent at 5769633bd95e and 943f200f69; Platform and ARC Ops report to cto. Shared inboundAdmission.test.ts asserts the new edge and passed, which shows the code disagrees with the registry."
    },
    {
      "id": "F3",
      "severity": "important",
      "outcome": "confirmed",
      "rechecked_head": "18436729ac06d036b738faaa8afe5a2ac71a7f1f",
      "file": "apps/server/src/orchestration-v2/InboundAdmission.ts",
      "line": 386,
      "summary": "A cap to steer_at_tool_boundary rewrites dispatchMode from restart_active to steer_active and drops deliveryIntent. Orchestrator then requests steer, and resolveDeliveryIntent returns steer_active instead of restarting the active turn.",
      "check": "Read applyInboundAdmissionToCommand, Orchestrator.ts delivery-class intent, and CommandPolicy.resolveDeliveryIntent. vp test run -t steer_active passed the downgrade assertion at 18436729ac06d036b738faaa8afe5a2ac71a7f1f"
    },
    {
      "id": "F4",
      "severity": "nit",
      "outcome": "fixed",
      "file": "apps/server/src/mcp/OrchestratorMcpService.ts",
      "line": 4084,
      "summary": "In observe mode with capped true, t3_thread_send omits deliveryReason, so an uncapped deliveryClass is not paired with a cap reason. Enforced caps still return the reason.",
      "check": "vp test run OrchestratorMcpService.activity.test.ts -t deliveryReason passed: observe capped reason undefined, observe uncapped reason kept, enforce capped reason returned"
    }
  ]
}

@nullStack65

Copy link
Copy Markdown
Owner Author

RESULT

Note

🤖 Grok 4.7 responding on behalf of nullStack65

Focused re-check of F2 only, Neon round 2318a245-a08e-487f-86ce-8dded636e0cf, on head 18436729ac06d036b738faaa8afe5a2ac71a7f1f. F2 is confirmed. F1, F3, and F4 are unchanged.

F2. DEFAULT_SEAT_REPORTS_TO sets gardening: "cto" at packages/shared/src/inboundAdmission.ts:94. The unit test resolves direct and transitive standing seat managers expects isInReportsToChain("CTO", "Gardening") and isInReportsToChain("CEO", "Gardening") to be true. The unit test rejects peers, subordinates, self, and cyclic maps expects isInReportsToChain("Gardening", "CTO") to be false.

That edge matches the current registry. closura-agent-config origin/master 9f9807a5a3928ad23f6869b78081699f8d42b9b1, commit 3777a9c018 (Place Gardening under CTO in the chain of command, CLO-1001), adds "reportsTo": "cto" on the roles[] entry "role": "gardening". docs/org-chain-of-command.md line 12 lists Gardening directly under CTO, with Platform and ARC Ops. The checkout at /home/primary/src/closura-agent-config is still 943f200f69 on gardening/clo-1351-landing, 92 commits behind origin/master, and that worktree copy still has no reportsTo on gardening. The confirmed registry is origin/master.

{
  "reviewed_base": "6382e077dede0c225c1cac0c7b2c4ec14e0a04a8",
  "reviewed_head": "18436729ac06d036b738faaa8afe5a2ac71a7f1f",
  "reviewer": "grok-4.7 (t3/grok-direct)",
  "author_session": "mcp:launch:7aeae44da2405bd57e60ae88cb8c8a34d10c920bd7a031ab1fced22102bdd079",
  "reviewer_session": "grok-direct:01a2403f-7e3c-7d62-bc48-e92cecc03acc",
  "fresh_context": true,
  "review_kind": "focused_recheck",
  "round_id": "2318a245-a08e-487f-86ce-8dded636e0cf",
  "intent": [
    "CLO-1368 M0-2/3: implement Inbound Cap v0 in packages/shared/src/inboundAdmission.ts and append-only runtime_decisions log in observe mode"
  ],
  "prior_findings": [
    "F2"
  ],
  "findings": [
    {
      "id": "F1",
      "severity": "important",
      "outcome": "confirmed",
      "rechecked_head": "18436729ac06d036b738faaa8afe5a2ac71a7f1f",
      "file": "apps/server/src/orchestration-v2/InboundAdmission.ts",
      "line": 90,
      "summary": "ACTIONABLE_PR_SUMMARY_RE now matches pullRequestWatch summaries '#<n>: new comments' and '#<n>: checks await approval' (comments? and await(?:ing)? approval). Enforce-mode dispatch of those updated outcomes is pr_actionable and wakes the covered seat.",
      "check": "node regex samples matched both producer strings and rejected '#482: checks passed'; vp test run apps/server InboundAdmission.test.ts -t 'new comments' passed at 18436729ac06d036b738faaa8afe5a2ac71a7f1f"
    },
    {
      "id": "F2",
      "severity": "important",
      "outcome": "confirmed",
      "file": "packages/shared/src/inboundAdmission.ts",
      "line": 94,
      "summary": "The repair's gardening: cto edge matches the current registry. closura-agent-config origin/master 9f9807a5 (3777a9c018, CLO-1001) sets roles[] gardening reportsTo to cto. docs/org-chain-of-command.md line 12 lists Gardening directly under CTO. Head 18436729 sets DEFAULT_SEAT_REPORTS_TO gardening to cto at packages/shared/src/inboundAdmission.ts:94, and inboundAdmission.test.ts asserts isInReportsToChain(CTO and CEO, Gardening) true and the reverse false.",
      "check": "git show origin/master:config/standing-threads.json at 9f9807a5a3928ad23f6869b78081699f8d42b9b1: roles[] role gardening reportsTo is cto (not an org.seats entry). org-chain-of-command.md line 12 is Gardening under CTO. git show 18436729ac06d036b738faaa8afe5a2ac71a7f1f:packages/shared/src/inboundAdmission.ts line 94 is gardening: cto; inboundAdmission.test.ts lines 278-279 and 287 assert the chain. The worktree at 943f200f69 is 92 commits behind origin/master and still omits reportsTo; the confirmed source is origin/master.",
      "rechecked_head": "18436729ac06d036b738faaa8afe5a2ac71a7f1f"
    },
    {
      "id": "F3",
      "severity": "important",
      "outcome": "confirmed",
      "rechecked_head": "18436729ac06d036b738faaa8afe5a2ac71a7f1f",
      "file": "apps/server/src/orchestration-v2/InboundAdmission.ts",
      "line": 386,
      "summary": "A cap to steer_at_tool_boundary rewrites dispatchMode from restart_active to steer_active and drops deliveryIntent. Orchestrator then requests steer, and resolveDeliveryIntent returns steer_active instead of restarting the active turn.",
      "check": "Read applyInboundAdmissionToCommand, Orchestrator.ts delivery-class intent, and CommandPolicy.resolveDeliveryIntent. vp test run -t steer_active passed the downgrade assertion at 18436729ac06d036b738faaa8afe5a2ac71a7f1f"
    },
    {
      "id": "F4",
      "severity": "nit",
      "outcome": "fixed",
      "file": "apps/server/src/mcp/OrchestratorMcpService.ts",
      "line": 4084,
      "summary": "In observe mode with capped true, t3_thread_send omits deliveryReason, so an uncapped deliveryClass is not paired with a cap reason. Enforced caps still return the reason.",
      "check": "vp test run OrchestratorMcpService.activity.test.ts -t deliveryReason passed: observe capped reason undefined, observe uncapped reason kept, enforce capped reason returned"
    }
  ]
}

@nullStack65 nullStack65 added the size-approved Founder accepted this PR over the 1500-line size gate label Dec 5, 2026
@nullStack65

Copy link
Copy Markdown
Owner Author

Superseded by nullStack65/t3code-private#65 (https://github.com/nullStack65/t3code-private/pull/65).

Custom T3 work belongs in the private fork: this repo's push guard blocks pushes of it, and the fork rule (rule 19) says a T3 change ships as the fork's default. The branch is rebased onto the private fork's release/native-0.1.10 at head d3ee0775f31364184bc55ab4200aed5e4541579a. Closing this pull request as superseded; the founder sign-off stays unraised until the private pull request is mergeable.

Model: grok-4.7
Task: CLO-1368
Agent: cto

@nullStack65 nullStack65 closed this Dec 5, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size-approved Founder accepted this PR over the 1500-line size gate

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant